package com.mojo.concurrent.concurrent_01_thread;

import java.util.Arrays;

/**
 * @author <a href="mailto:mojo_jj@163.com">Mojo</a>
 */
public class ThreadDemo01 {
    private static final Integer[] ARR = {1, 2, 3};

    public static void main(String[] args) throws InterruptedException {
        MyThread myThread = new MyThread();
        myThread.start();
        /*Thread类相关属性和方法
         * 1-name              线程名称
         * 2-isDaemon()        判断是否守护线程
         * 3-target            将可执行的目标任务
         * 4-currentThread()   返回当前线程信息对象
         * 5-sleep(Long mills) 线程睡眠并让出CPU时间
         * 6-yield()
         * */
        System.out.println("线程名称" + myThread.getName());
        System.out.println("守护进程判断>>>:" + myThread.isDaemon());
        // 5-wait()            放弃锁+等待0ms+尝试获取锁
        myThread.wait();
        // 7-notify()          唤醒线程
        myThread.notify();
        Thread thread = new Thread("黑马") {
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {

                    System.out.println(i + "+" + getName());
                }
            }
        };
        System.out.println("等待线程执行完毕加入>>>>>>>>>>>>>>>>>>>>>>>");
        myThread.join();
        System.out.println("等待完毕>>>>>>>>>>>>>>>>>>>>>>>");
        //thread.start();
        ThreadDemo01 t = new ThreadDemo01();
        System.out.println(ThreadDemo01.ARR.getClass().getName());
        System.out.println(Arrays.toString(ARR));
        changeArr(ARR);
        System.out.println(ThreadDemo01.ARR.getClass().getName());
        System.out.println(Arrays.toString(ARR));

    }

    private static void changeArr(Integer[] arr) {
        arr[0] = 4;
    }
}
